/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package fr.irit.etracetool.etrace.impl;

import java.util.Collection;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;

import fr.irit.etracetool.etrace.ETrace;
import fr.irit.etracetool.etrace.EtracePackage;
import fr.irit.etracetool.etrace.LinkType;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>ETrace</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link fr.irit.etracetool.etrace.impl.ETraceImpl#getName <em>Name</em>}</li>
 *   <li>{@link fr.irit.etracetool.etrace.impl.ETraceImpl#getTypeList <em>Type List</em>}</li>
 *   <li>{@link fr.irit.etracetool.etrace.impl.ETraceImpl#getDeletedElement <em>Deleted Element</em>}</li>
 *   <li>{@link fr.irit.etracetool.etrace.impl.ETraceImpl#getExternalElement <em>External Element</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class ETraceImpl extends CompositeLinkImpl implements ETrace {
	/**
	 * The default value of the '{@link #getName() <em>Name</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getName()
	 * @generated
	 * @ordered
	 */
	protected static final String NAME_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getName() <em>Name</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getName()
	 * @generated
	 * @ordered
	 */
	protected String name = NAME_EDEFAULT;

	/**
	 * The cached value of the '{@link #getTypeList() <em>Type List</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getTypeList()
	 * @generated
	 * @ordered
	 */
	protected EList<LinkType> typeList;

	/**
	 * The cached value of the '{@link #getDeletedElement() <em>Deleted Element</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getDeletedElement()
	 * @generated
	 * @ordered
	 */
	protected EList<EObject> deletedElement;

	/**
	 * The cached value of the '{@link #getExternalElement() <em>External Element</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getExternalElement()
	 * @generated
	 * @ordered
	 */
	protected EList<EObject> externalElement;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ETraceImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return EtracePackage.Literals.ETRACE;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getName() {
		return name;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setName(String newName) {
		String oldName = name;
		name = newName;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, EtracePackage.ETRACE__NAME, oldName, name));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<LinkType> getTypeList() {
		if (typeList == null) {
			typeList = new EObjectContainmentEList<LinkType>(LinkType.class, this, EtracePackage.ETRACE__TYPE_LIST);
		}
		return typeList;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<EObject> getDeletedElement() {
		if (deletedElement == null) {
			deletedElement = new EObjectContainmentEList<EObject>(EObject.class, this, EtracePackage.ETRACE__DELETED_ELEMENT);
		}
		return deletedElement;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<EObject> getExternalElement() {
		if (externalElement == null) {
			externalElement = new EObjectContainmentEList<EObject>(EObject.class, this, EtracePackage.ETRACE__EXTERNAL_ELEMENT);
		}
		return externalElement;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case EtracePackage.ETRACE__TYPE_LIST:
				return ((InternalEList<?>)getTypeList()).basicRemove(otherEnd, msgs);
			case EtracePackage.ETRACE__DELETED_ELEMENT:
				return ((InternalEList<?>)getDeletedElement()).basicRemove(otherEnd, msgs);
			case EtracePackage.ETRACE__EXTERNAL_ELEMENT:
				return ((InternalEList<?>)getExternalElement()).basicRemove(otherEnd, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case EtracePackage.ETRACE__NAME:
				return getName();
			case EtracePackage.ETRACE__TYPE_LIST:
				return getTypeList();
			case EtracePackage.ETRACE__DELETED_ELEMENT:
				return getDeletedElement();
			case EtracePackage.ETRACE__EXTERNAL_ELEMENT:
				return getExternalElement();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@SuppressWarnings("unchecked")
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case EtracePackage.ETRACE__NAME:
				setName((String)newValue);
				return;
			case EtracePackage.ETRACE__TYPE_LIST:
				getTypeList().clear();
				getTypeList().addAll((Collection<? extends LinkType>)newValue);
				return;
			case EtracePackage.ETRACE__DELETED_ELEMENT:
				getDeletedElement().clear();
				getDeletedElement().addAll((Collection<? extends EObject>)newValue);
				return;
			case EtracePackage.ETRACE__EXTERNAL_ELEMENT:
				getExternalElement().clear();
				getExternalElement().addAll((Collection<? extends EObject>)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case EtracePackage.ETRACE__NAME:
				setName(NAME_EDEFAULT);
				return;
			case EtracePackage.ETRACE__TYPE_LIST:
				getTypeList().clear();
				return;
			case EtracePackage.ETRACE__DELETED_ELEMENT:
				getDeletedElement().clear();
				return;
			case EtracePackage.ETRACE__EXTERNAL_ELEMENT:
				getExternalElement().clear();
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case EtracePackage.ETRACE__NAME:
				return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name);
			case EtracePackage.ETRACE__TYPE_LIST:
				return typeList != null && !typeList.isEmpty();
			case EtracePackage.ETRACE__DELETED_ELEMENT:
				return deletedElement != null && !deletedElement.isEmpty();
			case EtracePackage.ETRACE__EXTERNAL_ELEMENT:
				return externalElement != null && !externalElement.isEmpty();
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (name: ");
		result.append(name);
		result.append(')');
		return result.toString();
	}

} //ETraceImpl
